﻿using System;
using System.Collections.Generic;
using System.ServiceModel;

using Pg.BioMedics.SDR.Entities;

namespace Pg.BioMedics.SDR.Web.Services
{
    /// <summary>
    /// The service contract for Operational web service
    /// </summary>
    [ServiceContract]
    public interface IOperationalWebService
    {
        /// <summary>
        /// Registers a new document with the given content
        /// </summary>
        /// <param name="document">Document metadata entity</param>
        /// <param name="content">Document content</param>
        /// <returns>Registered document</returns>
        [OperationContract]
        void RegisterDocument(Document document, Content content);

        /// <summary>
        /// Gets document authored by the user authenticated in the context
        /// </summary>
        /// <returns>List of documents</returns>
        [OperationContract]
        IList<Document> GetDocuments();

        /// <summary>
        /// Removes given document authored by the user currently authenticated in the context
        /// </summary>
        /// <param name="document">Document instance</param>
        [OperationContract]
        void RemoveDocument(Document document);

        /// <summary>
        /// Registers a new annotation to the document
        /// </summary>
        /// <param name="document"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        [OperationContract]
        void RegisterAnnotation(Document document, Content content);

        /// <summary>
        /// Executes text query against stored documents and annotations
        /// </summary>
        /// <param name="query">Text query</param>
        /// <returns>List of query results</returns>
        [OperationContract]
        IList<SearchResult> ExecuteTextQuery(string query);

        /// <summary>
        /// Executes spoken query against stored documents and annotations
        /// </summary>
        /// <param name="spokenQuery">Spoken query</param>
        /// <param name="timeout">Query timeout</param>
        /// <returns>List of query results</returns>
        [OperationContract]
        IList<SearchResult> ExecuteSpokenQuery(byte[] spokenQuery, int timeout);

        /// <summary>
        /// Gets document related with the given search result 
        /// </summary>
        /// <param name="searchResult">Search result entity</param>
        /// <returns>Document</returns>
        [OperationContract]
        Document GetDocument(SearchResult searchResult);

        /// <summary>
        /// Gets document content
        /// </summary>
        /// <param name="document">Document metadata entity</param>
        /// <returns>Documents content</returns>
        [OperationContract]
        Content GetContent(Document document);

        /// <summary>
        /// This method is used by infrastructure for checking service status
        /// </summary>
        [OperationContract]
        string CheckStatus();
    }
}
